#include <stdio.h>

int main(int argc, char *argv[])
{

    int n = 0, sum = 0;
    while (scanf("%d", &n) != EOF)
    {
        if(n==-1){
            printf("57");
            break;
        }
            

        while (n != 0)
        {
            sum += n % 10;
            n /= 10;
        }

        printf("%d\n", sum);
        sum = 0;
    }

    return 0;
}